<template>
    <div>
        <h1>登录</h1>
        <table border="1px" class="table table-bordered">
            <tbody>
                <tr>
                    <td align="right">账户</td>
                    <td>
                        <input type="text" v-model="info.name">
                    </td>
                </tr>
                <tr>
                    <td align="right">密码</td>
                    <td>
                        <input type="password" v-model="info.pwd">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="登录" class="btn btn-primary" @click="ok">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref,reactive,onMounted} from 'vue'
import axios from 'axios';
import {useRouter} from 'vue-router'
import { log } from 'console';
const router = useRouter();

let info : any = reactive({
    name : '',
    pwd :''
})

const ok = () => {
    if(info.name==""){
        alert('账户不能为空!');
        return;
    }
    if(info.pwd==""){
        alert('密码不能为空!');
        return;
    }
    axios({
        url:'https://localhost:7086/api/Housenumber/Logn',
        method:'get',
        params:info
    })
    .then((res)=>{
        console.log(res.data); 
        if(res.data!=""){
            alert('登录成功!');
            router.push('/show');
            return;
        }
        else{
            alert('登录失败!');
            return;
        }
    })
}

</script>

<style scoped>

</style>